#ifndef utilitiespanel_h
#define utilitiespanel_h

#include "juce_amalgamated.h"
#include "BoundedPanel.h"
#include "SwitchablePanel.h"
#include "BackButton.h"
#include "Utilities/BMIPanel.h"
#include "Utilities/CaloriePanel.h"
#include "Utilities/UnitConverterPanel.h"

class UtilitiesPanel: public BoundedPanel, public SwitchablePanel {
private:
	BMIPanel* bmi;
	CaloriePanel* calorie;
	UnitConverterPanel* converter;
	BackButton* backButton;

public:
	UtilitiesPanel(MasterComponent* master, int w, int h) :
		BoundedPanel(w, h), SwitchablePanel(master) {

		int spacer = 30; //spacing between subpanels
		int subWidth = (width - 3 * spacer) / 2; //subpanel width
		int topSpacer = 100; //spacing at top

		addAndMakeVisible(calorie = new CaloriePanel());
		addAndMakeVisible(bmi = new BMIPanel());
		addAndMakeVisible(converter = new UnitConverterPanel());
		addAndMakeVisible(backButton = new BackButton((SwitchablePanel*)this));

		bmi->setBounds(spacer, topSpacer, subWidth, (int)((height - 2 * spacer - topSpacer) * 0.6));
		converter->setBounds(spacer, bmi->getHeight() + spacer + topSpacer, subWidth, (int)((height - 2 * spacer - topSpacer) * 0.4));
		calorie->setBounds((width + spacer) / 2, topSpacer, subWidth, (height - spacer - topSpacer));
		backButton->setBounds(35, 35, 40, 40);

		backButton->setFromTo(MasterComponent::UTILITIES, MasterComponent::MAIN);
	}

	void paint(Graphics& g) {
		//		g.drawSingleLineText(T("Utilities"), 0, 0);
		Rectangle r(0, 0, width, height);
		g.setColour(Colour(240, 240, 220));
		g.fillRoundedRectangle(r, 50);
		g.setColour(Colours::slategrey);
		MiscGraphics::drawRoundedRect(g, r, 50, 1);
		g.setColour(Colours::black);
		g.setFont(Font(Font::getDefaultSansSerifFontName(), 36, Font::plain));
		g.drawFittedText(T("Utilities"), 0, 0, width, 100, Justification::centred, 1);
	}

	void mouseDown(const MouseEvent& e) {
	}

	void switchPanels(int from, int to) {
		master->switchPanels(from, to);
	}
};

#endif

